package com.tiance.demo.service.mysql.bo;

import com.tiance.demo.service.mysql.utils.ByteUtils;

public class Page {

    public Page(byte[] bytes) {
        this.bytes = bytes;
    }

    //一个页的大小是16384字节
    public static final int SIZE = 16 * 1024;

    /**
     * 索引页，也就是我们所说的数据页, 0x45BF
     */
    public static final String FIL_PAGE_INDEX = "45 BF";
    public static final String FIL_PAGE_UNDO_LOG = "00 02";

    private byte[] bytes;

    protected FileHeader fileHeader;

    protected FileTailer fileTailer;

    public FileHeader getFileHeader() {
        return fileHeader;
    }

    public void setFileHeader(FileHeader fileHeader) {
        this.fileHeader = fileHeader;
    }

    public FileTailer getFileTailer() {
        return fileTailer;
    }

    public void setFileTailer(FileTailer fileTailer) {
        this.fileTailer = fileTailer;
    }

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    @Override
    public String toString() {
        return "Page:\n============\n" + fileHeader +
                "\n" + fileTailer +
                ' ';
    }

    public static void main(String[] args) {
        System.out.println(ByteUtils.hexStr2Bytes("a"));
    }
}
